<?php
namespace App\Services\Integral;

use App\Services\Integral\Integral\IntegralLogic;

/**
 * @Author: ws
 * @Date:   2019-02-20 16:23:45
 * @Last Modified by:   Marte
 */
class Integral
{
    /*积分操作（增加扣除）（接单成功奖励等）*/
    public function addIntegral($data): array
    {
        if (empty($data)) {
            return null_data($data,"参数不能为空！");
        }
        $data = init_array($data, ['user_id'=>0,'remark'=>'']);
        ValidateIntegral::checkValidate($data, ['user_id','remark']);
        return (new IntegralLogic())->addIntegral($data);
    }


    /*用户积分详情*/
    public function integralInfo($data): array
    {
        $data = init_array($data, ['user_id' => 0]);
        ValidateIntegral::checkValidate($data, ['user_id']);
        return (new IntegralLogic())->integralInfo($data);
    }

    /*用户积分记录*/
    public function integralList($data): array
    {
        $data = init_array($data, ['user_id'=>0]);
        ValidateIntegral::checkValidate($data, ['user_id']);
        return (new IntegralLogic())->integralList($data);
    }

    /*兑换*/
    public function addOrder($data): array
    {
        $data = init_array($data, ['user_id' => 0,'goods_id' => 0,'remark' => 0,'number' => 0,'addr_id' => 0,'name' => '','phone' => '','pay_password' => '']);
        ValidateIntegral::checkValidate($data, ['goods_id','user_id','number','addr_id','name','phone','pay_password']);
        return (new IntegralLogic())->addOrder($data);

    }

    /*兑换记录列表*/
    public function orderList($data): array
    {
        $data = init_array($data, ['user_id'=>0]);
        ValidateIntegral::checkValidate($data, ['user_id']);
        return (new IntegralLogic())->orderList($data);
    }

    /*用户积分列表 可查用户*/
    public function adminIntegralList($data): array
    {
        $data = init_array($data, ['keywords'=>'']);
        return (new IntegralLogic())->adminIntegralList($data);
    }
    /*积分操作记录 可查用户*/
    public function adminOptionLog($data): array
    {
        $data = init_array($data, ['keywords'=>'']);
        return (new IntegralLogic())->adminOptionLog($data);

    }
    /*用户兑换记录列表 可查用户*/
    public function adminOrderList($data): array
    {
        $data = init_array($data, ['keywords'=>'']);
        return (new IntegralLogic())->adminOrderList($data);

    }
    /*发货*/
    public function deliverGoods($data): array
    {
        $data = init_array($data, ['id'=>0]);
        ValidateIntegral::checkValidate($data, ['id']);
        return (new IntegralLogic())->deliverGoods($data);

    }

}
